package com.zrx.app.android.activity;

import android.app.Fragment;
import android.app.FragmentTransaction;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.zrx.app.android.R;
import com.zrx.app.android.fragment.calculators.Cal0Frag;
import com.zrx.app.android.fragment.calculators.Cal1Frag;
import com.zrx.app.android.fragment.calculators.Cal2Frag;
import com.zrx.app.android.modules.BaseModule;

public class CalculatorActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_calculator);
        //findViewById(R.id.btnAudit).setOnClickListener((v)->ListActivity.startActivity(this));
        final CalculatorActivity self = this;

        final View frame = findViewById(R.id.calFrame);
        findViewById(R.id.btnCal0).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {     //动态加载页面
                Fragment frag = Cal2Frag.newInstance(R.raw.cal0);
                FragmentTransaction ft = getFragmentManager().beginTransaction();
                ft.replace(R.id.calFrame, frag);
                ft.commit();
            }
        });
        findViewById(R.id.btnCal1).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Fragment frag = Cal2Frag.newInstance(R.raw.cal1);
                FragmentTransaction ft = getFragmentManager().beginTransaction();
                ft.replace(R.id.calFrame, frag);
                ft.commit();
            }
        });
        findViewById(R.id.btnCal2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Fragment frag = Cal2Frag.newInstance(R.raw.cal2);
                FragmentTransaction ft = getFragmentManager().beginTransaction();
                ft.replace(R.id.calFrame, frag);
                ft.commit();
            }
        });
        findViewById(R.id.btnCal3).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Fragment frag = Cal2Frag.newInstance(R.raw.cal3);
                FragmentTransaction ft = getFragmentManager().beginTransaction();
                ft.replace(R.id.calFrame, frag);
                ft.commit();
            }
        });
        findViewById(R.id.btnCal4).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Fragment frag = Cal2Frag.newInstance(R.raw.cal4);
                FragmentTransaction ft = getFragmentManager().beginTransaction();
                ft.replace(R.id.calFrame, frag);
                ft.commit();
            }
        });
        findViewById(R.id.btnCal5).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Fragment frag = Cal2Frag.newInstance(R.raw.cal5);
                FragmentTransaction ft = getFragmentManager().beginTransaction();
                ft.replace(R.id.calFrame, frag);
                ft.commit();
            }
        });
        findViewById(R.id.btnCal6).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Fragment frag = Cal2Frag.newInstance(R.raw.cal6);
                FragmentTransaction ft = getFragmentManager().beginTransaction();
                ft.replace(R.id.calFrame, frag);
                ft.commit();
            }
        });
        findViewById(R.id.btnCal7).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Fragment frag = Cal2Frag.newInstance(R.raw.cal7);
                FragmentTransaction ft = getFragmentManager().beginTransaction();
                ft.replace(R.id.calFrame, frag);
                ft.commit();
            }
        });


        Fragment frag = Cal2Frag.newInstance(R.raw.cal0);
        FragmentTransaction ft = getFragmentManager().beginTransaction();
        ft.replace(R.id.calFrame, frag);
        ft.commit();

    }
    public static void startActivity(Context context) {
        Intent intent = new Intent(context,CalculatorActivity.class);
        context.startActivity(intent);
    }

}
